﻿@model WebApplication.Models.ReportParameter

<script src="../../../Scripts/jquery-1.7.1.js"></script>
<script src="../../../Scripts/jquery-ui-1.8.20.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">

<script type="text/javascript">
 
    $(document).ready(function () {

        $('#modalServers').dialog({
            autoOpen: false,
            height: 345,
            width: 330,
            show: { effect: "toggle", duration: 800 },
            buttons: {
                "Применить": function () {
                    $('#serverChoose').html('');
                    $('#serverChoose').removeClass("alert-info").addClass("alert-success");
                    $("input#serverChk:checked").each(function () {
                        var id = $(this).attr('idNot');
                        var name = $(this).attr('nameNot');
                        var descr = $(this).attr('descr');
                        $('#serverChoose').append('<input type="hidden" name="@Model.Name" value="' + id + '" />');

                    $('#serverChoose').append('<div>Выбран сервер: ' + name + ' (' + descr + ')</div>');

                });
                //$(this).dialog('close');
            }
        },
            zIndex: 100000
        });

    })
    
        function chooseServer(e) {
            $('#modalServers').html('');
            
            $.ajax({
                url: "/Server/GetNotDeletedServers",
                type: "GET",
                success: function (data) {
                    $('#modalServers').html(data);
                }
            })
            $('#modalServers').dialog('open');
        }

</script>

<div class="well">
    <div id="serverChoose" class="alert alert-info">
        Ничего не выбрано
    </div>
    <input type="button" class="btn btn-primary btn-small" onclick="chooseServer(event);" value="Выбрать сервер" id="btnServerChoose" />
</div>

<div id="modalServers" title="Выбор сервера">

</div>